package xyz.lwm.lazycat.beans;

import xyz.lwm.lazycat.utility.StringUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * bean name renamer
 *
 * @author lwm
 */
class BeanRenamers implements BeanRenamer {

    private final List<BeanRenamer> renamers = new ArrayList<>();

    public void add(BeanRenamer renamer) {
        renamers.add(renamer);
    }

    @Override
    public String rename(BeanDesign<?> design) {
        String beanName = design.getName();
        for (BeanRenamer renamer : renamers) {
            String rename = renamer.rename(design);
            if (StringUtil.isNotBlank(rename)) {
                beanName = rename;
            }
        }
        return beanName;
    }

}
